package design_patterns

import "fmt"

type Mobile interface {
	Call(telNum string)
	Connect5G()
}

type XiaoMi struct {
	Brand string
}

func (m XiaoMi) Call(telNum string) {
	fmt.Printf("%s拨打电话%s\n", m.Brand, telNum)
}

func (m XiaoMi) Connect5G() {
	fmt.Printf("%s连接5G网络\n", m.Brand)
}

type HuaWei struct {
	Brand string
}

func (h HuaWei) Call(telNum string) {
	fmt.Printf("%s拨打电话%s\n", h.Brand, telNum)
}

func (h HuaWei) Connect5G() {
	fmt.Printf("%s连接5G网络\n", h.Brand)
}

func NewMobile(t int) Mobile {
	if t == 1 {
		return &XiaoMi{}
	} else if t == 2 {
		return &HuaWei{}
	}
	return nil
}
